﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using Newtonsoft.Json;

public partial class report_jggz : Basic
{
    public string strJGGZ = "";
    public string str04 = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        strJGGZ = sb机构首次关注().ToString();
        str04 = Pub.strSCJD();
    }


    protected StringBuilder sb机构首次关注()
    {
        StringBuilder sb = new StringBuilder();
        try
        {
            int page = OTO.ToInt(Request["page"], 1);
            if (page == 0)
                page = 1;
            int _totalCount = 0;
            int _pagesize = 15;
            int _totalPage = 0;
            int _index = (page - 1) * _pagesize;

            string url = jsonUrl + "stock/StockPool_GetOne.ashx?flag=jgscgz&skip=" + _index + "&top=" + _pagesize + "";
            string str = Pub.LoadData(url);
            NewStock_BData_C obj = JsonConvert.DeserializeObject<NewStock_BData_C>(str);

            _totalCount = obj.count;
            if (_totalCount > 0)
            {
                if ((_totalCount % _pagesize) == 0)
                    _totalPage = _totalCount / _pagesize;
                else
                    _totalPage = (int)(_totalCount / _pagesize) + 1;
            }
            if (page > _totalPage)
                page = _totalPage;

            string strPage = "<div class=\"news_next\">" + PageHelper.fy(_totalCount, _pagesize, page, Request.Url.AbsoluteUri) + "</div>";

            sb.AppendLine("<div class=\"tableLarge\">");
            sb.AppendLine("<table align=\"center\" width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">");
            sb.AppendLine("<tr bgcolor=\"#f2f2f2\">");
            sb.AppendLine("<td rowspan=\"2\">序号</td>");
            sb.AppendLine("<td rowspan=\"2\">证券代码</td>");
            sb.AppendLine("<td rowspan=\"2\">证券简称</td>");
            sb.AppendLine("<td rowspan=\"2\">研究机构</td>");
            sb.AppendLine("<td rowspan=\"2\">最新评级</td>");
            sb.AppendLine("<td rowspan=\"2\">目标价</td>");
            sb.AppendLine("<td rowspan=\"2\">最新价</td>");
            sb.AppendLine("<td rowspan=\"2\">预期涨幅</td>");
            sb.AppendLine("<td colspan=\"2\">盈利预测</td>");
            sb.AppendLine("<td rowspan=\"2\">报告日期</td>");
            sb.AppendLine("<td rowspan=\"2\">报告摘要</td>");
            sb.AppendLine("</tr>");
            sb.AppendLine("<tr bgcolor=\"#f2f2f2\">");
            sb.AppendLine("<td>10E</td>");
            sb.AppendLine("<td>11E</td>");
            sb.AppendLine("</tr>");
            int i = 0;
            foreach (var m in obj.list)
            {
                i++;
                sb.AppendLine("<tr align=\"center\" onmouseover=\"this.className='tr_over'\" onmouseout=\"this.className='tr_out'\">");
                sb.AppendLine("<td>" + (_index + i) + "</td>");
                sb.AppendFormat("<td><a href=\"{0}gg{1}.shtml\" class=\"b\">{1}</a></td>", quoteUrl, m.StockId);
                sb.AppendFormat("<td><a href=\"{0}gg{1}.shtml\" class=\"b\">{2}</a></td>", quoteUrl, m.StockId, OTO.ToStr(m.StockName, "&nbsp;"));
                sb.AppendLine("<td>" + OTO.ToStr(m.OName, "&nbsp;") + "</td>");
                sb.AppendLine("<td>" + m.InvestmentGrade + "</td>");
                sb.AppendLine("<td class=\"red\">" + OTO.ToDecLine(m.TargetPrice, 2, "-") + "</td>");
                sb.AppendLine("<td><span zxj=\"zxj\" code=\"" + m.StockId + "\" class=\"red\">-</span></td>");
                sb.AppendLine("<td><span zdf=\"zdf\" zdfv=\"" + m.TargetPrice + "\">-</span></td>");
                sb.AppendLine("<td class=\"red\">" + OTO.ToDecLine(m.PerIncome1, 2, "-") + "</td>");
                sb.AppendLine("<td class=\"red\">" + OTO.ToDecLine(m.PerIncome2, 2, "-") + "</td>");
                sb.AppendLine("<td>" + OTO.ToDateLine(m.CDate, 1) + "</td>");
                sb.AppendFormat("<td><a href=\"reportContent_{0}.shtml\" class=\"b\">报告摘要</a></td>", m.id);
                sb.AppendLine("</tr>");
            }
            sb.AppendLine("</table>");
            sb.AppendLine("</div>");

            sb.AppendLine(strPage);

        }
        catch
        { }
        return sb;
    }

}